
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
  <meta charset="utf-8">
  <title>ksnowlv</title>
  <meta name="author" content="律威">

  
  <meta name="description" content="AFNetworking网络框架2.x是很优秀的，许多关键的技术细节处理的是很到位的。 AFNetworking 2.x可能改进点小结 1.可以根据需求，选用其中部分模块，并裁剪其中一些类。 2.目前网络模块不支持长连接。 3.NSCache的不当使用，可以调整优化。 &hellip;">
  

  <!-- http://t.co/dKP3o1e -->
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  
  <link rel="canonical" href="http://ksnowlv.github.io/blog/page/7">
  <link href="/favicon.png" rel="icon">
  <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
  <link href="/atom.xml" rel="alternate" title="ksnowlv" type="application/atom+xml">
  <script src="/javascripts/modernizr-2.0.js"></script>
  <script src="//ajax.useso.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script>!window.jQuery && document.write(unescape('%3Cscript src="./javascripts/lib/jquery.min.js"%3E%3C/script%3E'))</script>
  <script src="/javascripts/octopress.js" type="text/javascript"></script>
  <!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.useso.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.useso.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">

  
  <script type="text/javascript">
    var _gaq = _gaq || [];
     _gaq.push(['_setAccount', 'UA-39546615-2']);
    // _gaq.push(['_trackPageview']);

    // (function() {
    //   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    //   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    //   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    // })();

    _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src='http://droidyue-tools.qiniudn.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
  </script>


</head>

<body   >
  <header role="banner"><hgroup>
  <h1><a href="/">ksnowlv</a></h1>
  
    <h2>回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.</h2>
  
</hgroup>

</header>
  <nav role="navigation"><ul class="subscription" data-subscription="rss">
  <li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
  
</ul>
  
<form action="http://google.com/search" method="get">
  <fieldset role="search">
    <input type="hidden" name="q" value="site:ksnowlv.github.io" />
    <input class="search" type="text" name="q" results="0" placeholder="Search"/>
  </fieldset>
</form>
  
<ul class="main-navigation">
  <li><a href="/">博客首页</a></li>
  <li><a href="/blog/archives">文章列表</a></li>
  <!-- <li><a href="/about-me">关于我</a></li>
 -->
</ul>

</nav>
  <div id="main">
    <div id="content">
      <div class="blog-index">
  
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/09/05/afnetworking-2-dot-x-kuang-jia-ke-gai-jin-dian-zong-jie/">AFNetworking-2.x框架可改进点总结</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-09-05T14:10:00+08:00" pubdate data-updated="true">Sep 5<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/09/05/afnetworking-2-dot-x-kuang-jia-ke-gai-jin-dian-zong-jie/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p><strong>AFNetworking</strong>网络框架<strong>2.x</strong>是很优秀的，许多关键的技术细节处理的是很到位的。</p>

<h3>AFNetworking 2.x可能改进点小结</h3>

<h4>1.可以根据需求，选用其中部分模块，并裁剪其中一些类。</h4>

<h4>2.目前网络模块不支持长连接。</h4>

<h4>3.<strong>NSCache</strong>的不当使用，可以调整优化。</h4>

<p>   见<code>UIKit扩展</code>中<code>UIImageView (AFNetworking)</code>中</p>

<ul>
<li>1.如果没有对图片个数或占用内存大小作限制，如果使用过多，会造成内存占用过多引发crash;</li>
<li>2.如果做了图片个数或内存大小的限制，因为<strong>NSCache</strong>的淘汰策略是基于引用计数的，则通常不是我们所需求的，这也是系统提供的<strong>NSCache</strong>的尴尬之处。</li>
</ul>


<h4>4.<strong>UIKit扩展</strong>中<strong>UIButton (AFNetworking)</strong>图片不支持cache.</h4>

<h4>5.图片下载队列的优化调整。</h4>

<ul>
<li> 1.<strong>UIImageView (AFNetworking)</strong>和<strong>UIButton (AFNetworking)</strong>各使用一个<strong>NSOperationQueue</strong>,如果同时使用这两个控件，可以考虑使用同一个<strong>NSOperationQueue</strong>。</li>
<li> 2.鉴于我们应用当中图片使用量较大，不建议直接使用网络模块中的队列进行下载。</li>
</ul>


<h4>6.网络请求取消，可以完善下。</h4>

<h4>7.最好屏蔽网络请求暂停的接口.</h4>

<pre><code>网络请求暂停后，始终会停留在NSOperationQueue中，占用线程资源，影响其它线程的调度。
</code></pre>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/09/04/afnetworking-guan-yu-wang-luo-diao-yong-shi-xu-tu/">AFNetworking 2.x网络调用时序图</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-09-04T20:49:00+08:00" pubdate data-updated="true">Sep 4<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/09/04/afnetworking-guan-yu-wang-luo-diao-yong-shi-xu-tu/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>AFNetworking 2.x中，关于网络请求的并发是通过<code>NSOperation</code>&amp;<code>NSOperationQueue</code>实现的。</p>

<blockquote><ul>
<li>网络调用相关封装在<a href="https://developer.apple.com/library/ios/documentation/cocoa/reference/NSOperation_class/Reference/Reference.html#//apple_ref/doc/uid/TP40004591">NSOperation</a>的子类<code>AFURLConnectionOperation</code>中。</li>
<li>类<code>AFHTTPRequestOperationManager</code>通过<a href="https://developer.apple.com/library/ios/documentation/cocoa/reference/NSOperationQueue_class/Reference/Reference.html">NSOperationQueue</a>完成对<code>AFURLConnectionOperation</code>的调度，当<code>AFURLConnectionOperation</code>一旦被加入到<code>NSOperationQueue</code>中，就开始了对网络并发执行.</li>
<li><code>AFURLConnectionOperation</code>可以通过调用<code>start</code>方法单独执行，此时和<code>NSOperationQueue</code>无关的。</li>
</ul>
</blockquote>

<p><img src="/images/post/2014-09-04-afnetworking-guan-yu-wang-luo-diao-yong-shi-xu-tu/AFNNetworking_sequence_diagrams.jpg" alt="image" /></p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/09/04/afnetworking-2-dot-0-suo-you-xiang-mu-gai-lan/">AFNetworking-2.0所有项目概览</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-09-04T19:31:00+08:00" pubdate data-updated="true">Sep 4<span>th</span>, 2014</time>
        
         | <a href="/blog/2014/09/04/afnetworking-2-dot-0-suo-you-xiang-mu-gai-lan/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><h4>AFNetworking-2.x下所有项目概览</h4>

<p><img src="/images/post/2014-09-04-afnetworking-2-dot-0-suo-you-xiang-mu-gai-lan/AFNetworking_all_projects_overview.png" alt="image" /></p>

<h4>AFNetworking子项目地址：<a href="https://github.com/AFNetworking">https://github.com/AFNetworking</a></h4>

<p>子项目列表</p>

<blockquote><ul>
<li>1.<a href="https://github.com/AFNetworking/AFNetworkActivityLogger">AFNetworkActivityLogger</a></li>
<li>2.<a href="https://github.com/AFNetworking/AFAmazonS3Client">AFAmazonS3Client</a></li>
<li>3.<a href="https://github.com/AFNetworking/AFJSONRPCClient">AFJSONRPCClient</a></li>
<li>4.<a href="https://github.com/AFNetworking/Xcode-Project-Templates">Xcode-Project-Templates</a></li>
<li>5.<a href="https://github.com/AFNetworking/AFOnoResponseSerializer">AFOnoResponseSerializer</a></li>
<li>6.<a href="https://github.com/AFNetworking/WebKit-AFNetworking">WebKit-AFNetworking</a></li>
<li>7.<a href="https://github.com/AFNetworking/AFMsgPackSerialization">AFMsgPackSerialization</a></li>
<li>8.<a href="https://github.com/AFNetworking/AFCoreImageResponseSerializer">AFCoreImageResponseSerializer</a></li>
<li>9.<a href="https://github.com/AFNetworking/AFKissXMLRequestOperation">AFKissXMLRequestOperation</a></li>
<li>10.<a href="https://github.com/AFNetworking/afnetworking.com">afnetworking.com</a></li>
<li>11.<a href="https://github.com/AFNetworking/AFWebDAVManager">AFWebDAVManager</a></li>
<li>12.<a href="https://github.com/AFNetworking/AFOAuth2Client">AFOAuth2Client</a></li>
<li>13.<a href="https://github.com/AFNetworking/AFgzipRequestSerializer">AFgzipRequestSerializer</a></li>
<li>14.<a href="https://github.com/AFNetworking/AFOAuth1Client">AFOAuth1Client</a></li>
<li>15.<a href="https://github.com/AFNetworking/AFHTTPRequestOperationLogger">AFHTTPRequestOperationLogger</a></li>
<li>16.<a href="https://github.com/AFNetworking/AFRocketClient">AFRocketClient</a></li>
<li>17.<a href="https://github.com/AFNetworking/AFContentRequestOperations">AFContentRequestOperations</a></li>
<li>18.<a href="https://github.com/AFNetworking/AFIncrementalStore">AFIncrementalStore</a></li>
<li>19.<a href="https://github.com/AFNetworking/AFNetworking-ASIHTTPRequest">AFNetworking-ASIHTTPRequest</a></li>
<li>20.<a href="https://github.com/AFNetworking/AFCollectionJSONRequestOperation">AFCollectionJSONRequestOperation</a></li>
</ul>
</blockquote>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/09/03/afnnetworking-2-dot-0-lei-tu/">AFNNetworking-2.0-类图</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-09-03T20:11:00+08:00" pubdate data-updated="true">Sep 3<span>rd</span>, 2014</time>
        
         | <a href="/blog/2014/09/03/afnnetworking-2-dot-0-lei-tu/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p><img src="/images/post/2014-09-03-afnnetworking-2-dot-0-lei-tu/AFNNetworking_main_class_picture.jpg" alt="image" /></p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/09/02/ios-zhong-fan-she-de-ying-yong/">iOS中反射的应用</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-09-02T23:21:00+08:00" pubdate data-updated="true">Sep 2<span>nd</span>, 2014</time>
        
         | <a href="/blog/2014/09/02/ios-zhong-fan-she-de-ying-yong/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p>待写</p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/09/02/afnetworking-2-dot-0/">AFNetworking-2.0主项目</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-09-02T19:18:00+08:00" pubdate data-updated="true">Sep 2<span>nd</span>, 2014</time>
        
         | <a href="/blog/2014/09/02/afnetworking-2-dot-0/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><h4>AFNetworking-2.0主项目源代码文件组成：</h4>

<p><img src="/images/post/2014-09-02-afnetworking-2-dot-0/afnetworking_code_overview.png" alt="image" /></p>

<h4>AFNetworking-2.0主项目类组成：</h4>

<p><img src="/images/post/2014-09-02-afnetworking-2-dot-0/AFNetworking_class_overview.png" alt="image" /></p>

<h3><a href="https://github.com/AFNetworking/AFNetworking">AFNetworking 2.0</a>相比2.0做了优化调整。</h3>

<blockquote><ul>
<li>兼容NSURLSession，适配iOS7.</li>
<li>模块化，可以自由挑选你需要的模块。</li>
<li>实时推送。AFNetworking主项目并没有这个特性，而是放到子项目<a href="https://github.com/AFNetworking/AFRocketClient">AFRocketClient</a></li>
</ul>
</blockquote>

<p>中文译文为<a href="http://nshipster.cn/afnetworking-2/">http://nshipster.cn/afnetworking-2/</a></p>

<h4>版本支持情况</h4>

<table>
<thead>
<tr>
<th></th>
<th align="center">  AFNetworking 版本 &nbsp;&nbsp;&nbsp;&nbsp;</th>
<th align="center">   最低支持 iOS Target  &nbsp;&nbsp;&nbsp;&nbsp;</th>
<th align="center">     最低支持 OS X Target      &nbsp;&nbsp;&nbsp;&nbsp;</th>
<th align="center">     注意事项          &nbsp;&nbsp;&nbsp;&nbsp; </th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td align="center">          2.x      </td>
<td align="center">      iOS 6            </td>
<td align="center">           OS X 10.8          </td>
<td align="center"> Xcode 5 is required  </td>
</tr>
<tr>
<td></td>
<td align="center">          <a href="https://github.com/AFNetworking/AFNetworking/tree/1.x">1.x</a>      </td>
<td align="center">      iOS 5            </td>
<td align="center">         Mac OS X 10.7        </td>
<td align="center">                      </td>
</tr>
<tr>
<td></td>
<td align="center">         <a href="https://github.com/AFNetworking/AFNetworking/tree/0.10.x">0.10.x</a>    </td>
<td align="center">      iOS 4            </td>
<td align="center">         Mac OS X 10.6        </td>
<td align="center">                      </td>
</tr>
</tbody>
</table>


<h3><br>结构：<br></h3>

<h4>NSURLConnection</h4>

<ul>
<li><p><strong>AFURLConnectionOperation</strong></p>

<p>  <code>NSOperation</code>的子类，实现<code>NSURLConnectionDelegate</code>,
<code>NSURLConnectionDataDelegate</code>,控制<code>NSURLConnection</code>的创建，取消，
进行中，完成，并对外回调执行状态。</p></li>
<li><p><strong>AFHTTPRequestOperation</strong></p>

<p>   <code>AFURLConnectionOperation</code> 的子类，用于生成 <code>HTTP</code> 请求，可以区别可接受的和不可接受的状态码及内容类型。</p></li>
<li><p><strong>AFHTTPRequestOperationManager</strong>:</p>

<p>  继承 NSObject类，遵循<code>NSSecureCoding</code>, <code>NSCopying</code>协议，包装常见 HTTP web 服务操作的类，包括请求的创建，响应的序列化，网络状态监控，安全性。通过<code>NSOperationQueue</code>对象来调度<code>AFHTTPRequestOperation</code>对象。</p></li>
</ul>


<h4>小结：</h4>

<p>   1.AFURLConnectionOperation/AFHTTPRequestOperation及其子类共用享线程networkRequestThread的runloop,网络请求回调处理完后，准备好数据向上层调用者回调。</p>

<p>   2.使用状态机来控制NSOperation的状态切换，状态的改变通过在<code>setState</code>中通过KVO触发。</p>

<ul>
<li> AFOperationPausedState</li>
<li> AFOperationReadyState</li>
<li> AFOperationExecutingState</li>
<li> AFOperationFinishedState
默认为<code>AFOperationReadyState</code></li>
</ul>


<h4>NSURLSession支持 <em>(iOS 7 / Mac OS X 10.9)</em></h4>

<ul>
<li><p><strong>AFURLSessionManager</strong>：</p>

<p> 创建、管理基于 <code>NSURLSessionConfiguration</code> 对象的 <code>NSURLSession</code> 对象的类，也可以管理 session 的数据、下载/上传任务，实现 session 和其相关联的任务的 delegate 方法</p></li>
<li><strong>AFHTTPSessionManager</strong>：- <code>AFURLSessionManager</code> 的子类，包装常见的 HTTP web 服务操作，通过 <code>AFURLSessionManager</code>由<code>NSURLSession</code> 支持</li>
</ul>


<h4>小结：</h4>

<p>   目前还没有明确拒绝<code>NSURLConnection</code>,<code>iOS7</code>的<code>NSURLSession</code>是不是以后会逐步取代<code>NSURLConnection</code>？</p>

<h4>序列化(Serialization)</h4>

<ul>
<li><p><strong>&lt;AFURLRequestSerialization></strong></p>

<p>  符合这个协议的对象用于处理请求，它将请求参数转换为 query string 或是 entity body 的形式，并设置必要的 header。</p>

<ul>
<li><code>AFHTTPRequestSerializer</code>:http标准格式</li>
<li><code>AFJSONRequestSerializer</code>:json格式</li>
<li><code>AFPropertyListRequestSerializer</code>:属性列表格式</li>
</ul>
</li>
<li><p><strong>&lt;AFURLResponseSerialization></strong></p>

<p>  符合这个协议的对象用于验证、序列化响应及相关数据，转换为有用的形式，比如 JSON 对象、图像、甚至基于 Mantle 的模型对象</p>

<ul>
<li><code>AFHTTPResponseSerializer</code>：http标准格式</li>
<li><code>AFJSONResponseSerializer</code>:json格式</li>
<li><code>AFXMLParserResponseSerializer</code>:xml格式</li>
<li><code>AFXMLDocumentResponseSerializer</code> <em>(Mac OS X)</em></li>
<li><code>AFPropertyListResponseSerializer</code>:属性列表格式</li>
<li><code>AFImageResponseSerializer</code>:图片格式</li>
<li><code>AFCompoundResponseSerializer</code>:网络失败时的数据填充。</li>
</ul>
</li>
</ul>


<h4>小结:</h4>

<p>  主要是针对请求数据和响应数据格式的增强，提高易用性。</p>

<h4>Additional Functionality</h4>

<ul>
<li><code>AFSecurityPolicy</code>:https安全策略。</li>
<li><code>AFNetworkReachabilityManager</code>:网络状态监听。</li>
</ul>


<h4>UIKit 扩展支持(UIKit expansion)</h4>

<ul>
<li><code>AFNetworkActivityIndicatorManager</code>:新增自动开始或结束状态栏上的网络指示器。</li>
<li><code>UIImageView+AFNetworking</code>: 新增显示图片前剪裁或者加滤镜的功能。</li>
<li><code>UIButton+AFNetworking</code> (新增): 类似 UIImageView+AFNetworking，按钮的背景图从线上下载。</li>
<li><code>UIActivityIndicatorView+AFNetworking</code> (新增): 根据网络请求的状态自动开始或结束。</li>
<li><code>UIProgressView+AFNetworking</code> (新增): 自动跟踪某个请求的上传下载的进度。</li>
<li><code>UIWebView+AFNetworking</code> (新增): 支持网络请求的进度和内容转换。</li>
</ul>


<h4>小结:</h4>

<p>   提供一些和网络相关UI的扩展的支持,提高使用便捷性。</p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/31/mac-xia-an-zhuang-pei-zhi-mysql/">Mac下安装配置mysql</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-31T23:25:00+08:00" pubdate data-updated="true">Aug 31<span>st</span>, 2014</time>
        
         | <a href="/blog/2014/08/31/mac-xia-an-zhuang-pei-zhi-mysql/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><h4>1。下载安装MySQL.</h4>

<p>在<a href="http://dev.mysql.com/downloads/mysql/">mysql官网</a>找到<strong>Mac</strong>版本<strong>MySQL Community Server</strong>下载安装即可。</p>

<p>安装<strong>MySQL</strong>完成后，在在<strong>MySQL的控制面板</strong>(系统偏好设置->MySQL)中，启动<strong>mysql服务</strong>即可。</p>

<p>如遇到不能启动<strong>mysql服务</strong>，参考链接：<a href="http://ksnowlv.gitcafe.com/blog/2014/08/31/mac-mysql-service-can-not-start/">解决Mac-mysql-service-can‘t-start的问题</a>。</p>

<h4>2.安装MySQL Workbench(GUI Tool)</h4>

<p> 在<a href="http://dev.mysql.com/downloads/workbench/">mysql官网</a>找到<strong>Mac</strong>版本<strong>MySQL Workbench</strong>下载安装即可。</p>

<p> 安装启动成功后，创建phpDataBase的数据库连接。</p>

<p> <img src="/images/post/2014-08-31-mac-xia-an-zhuang-pei-zhi-mysql/mysql_workbench_overview.png" alt="image" /></p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/31/mac-mysql-service-can-not-start/">解决mac-mysql-service-can‘t-start的问题</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-31T22:26:00+08:00" pubdate data-updated="true">Aug 31<span>st</span>, 2014</time>
        
         | <a href="/blog/2014/08/31/mac-mysql-service-can-not-start/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p><code>Mac</code>上安装<a href="http://dev.mysql.com/downloads/mysql/">mysql-5.6.20-osx10.8-x86_64-3</a>完成。</p>

<p>在<strong>MySQL的控制面板</strong>(系统偏好设置->MySQL)上，显示<strong>mac mysql service can&rsquo;t start</strong>。</p>

<p><strong>解决方案</strong>：</p>

<p>编辑<code>/usr/local/mysql-5.6.20-osx10.8-x86_64/support-files/</code>目录下<code>mysql.server</code>文件,把</p>

<pre><code>basedir=
datadir=
</code></pre>

<p>替换为</p>

<pre><code>basedir=/usr/local/mysql 
datadir=/usr/local/mysql/data 
</code></pre>

<p>重启下<code>mysql service</code>，即可。</p>

<p>如果重启失败，重启下电脑吧。</p>

<p><code>mysql service</code>启动成功后的界面。</p>

<p><img src="/images/post/2014-08-31-mac-mysql-service-can-not-start/mysql_service_ok.png" alt="image" /></p>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/31/faux-pas-cha-zhao-yin-xing-bug-li-qi/">Faux Pas查找隐形bug利器</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-31T17:16:00+08:00" pubdate data-updated="true">Aug 31<span>st</span>, 2014</time>
        
         | <a href="/blog/2014/08/31/faux-pas-cha-zhao-yin-xing-bug-li-qi/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p><a href="http://fauxpasapp.com">Faux Pas</a>是一个Xcode辅助工具，查找隐形bug利器,</p>

<p>主要功能:</p>

<blockquote><ul>
<li>找出隐藏的<strong>bug</strong>。</li>
<li>查找资源文件的错误。</li>
<li>查找本地化的错误</li>
<li>查找版本控制的错误</li>
<li>学习和实施最佳实践</li>
<li>执行代码风格</li>
<li>获得代码审查清单</li>
<li>&hellip;</li>
</ul>
</blockquote>
</div>
  
  


    </article>
  
  
    <article>
      
  <header>
    
      <h1 class="entry-title"><a href="/blog/2014/08/31/xcconfig-wen-jian-de-shi-yong/">XCConfig文件的使用</a></h1>
    
    
      <p class="meta">
        








  


<time datetime="2014-08-31T14:01:00+08:00" pubdate data-updated="true">Aug 31<span>st</span>, 2014</time>
        
         | <a href="/blog/2014/08/31/xcconfig-wen-jian-de-shi-yong/#disqus_thread">Comments</a>
        
      </p>
    
  </header>


  <div class="entry-content"><p><strong>XCConfig:XCode</strong>的<strong>Config</strong>文件，可以方便的对项目工程进行配置。只需要引入该工程配置文件即可。</p>

<p>1.分别创建<strong>ConfigDebug.xcconfig</strong>/<strong>ConfigRelease.xcconfig</strong>文件</p>

<p><img src="/images/post/2014-08-31-xcconfig-wen-jian-de-shi-yong/xconfig_create.png" alt="image" /></p>

<p>2.分别把<strong>ConfigDebug.xcconfig</strong>/<strong>ConfigRelease.xcconfig</strong>引入到工程配置中</p>

<p><img src="/images/post/2014-08-31-xcconfig-wen-jian-de-shi-yong/xcconfig_use.png" alt="image" /></p>

<p>3.编辑<strong>ConfigDebug.xcconfig</strong>/<strong>ConfigRelease.xcconfig</strong>文件，分别<strong>对other link flag</strong>和<strong>Preprocessor Macros</strong>修改设置查看生效情况。</p>

<p>展开&#8221;<strong>other link flag</strong>&ldquo;后，直接选择<strong>Release</strong>整行复制到<strong>ConfigRelease.xcconfig</strong>中，再设置<strong>-ObjC</strong>，<strong>-weak_framework UIKit</strong>，<strong> -framework CoreLocation</strong>参数。</p>

<p>相同方法修改<strong>ConfigDebug.xcconfig</strong>即可。</p>

<p><strong>ConfigDebug.xcconfig</strong>内容如下:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="c1">//:configuration = Debug</span>
</span><span class='line'><span class="n">OTHER_LDFLAGS</span> <span class="o">=</span> <span class="o">-</span><span class="n">ObjC</span> <span class="o">-</span><span class="n">weak_framework</span> <span class="n">UIKit</span>  <span class="o">-</span><span class="n">framework</span> <span class="n">CoreLocation</span>
</span><span class='line'>
</span><span class='line'>
</span><span class='line'><span class="c1">//DEBUG __TAOBAOTEST__</span>
</span><span class='line'><span class="n">GCC_PREPROCESSOR_DEFINITIONS</span> <span class="o">=</span> <span class="n">__TAOBAOTEST__</span><span class="o">=</span> <span class="mi">0</span>  <span class="n">$</span><span class="p">(</span><span class="n">inherited</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>


<p><strong>ConfigRelease.xcconfig</strong>内容如下:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='objective-c'><span class='line'><span class="c1">//:configuration = Release</span>
</span><span class='line'><span class="n">OTHER_LDFLAGS</span> <span class="o">=</span> <span class="o">-</span><span class="n">ObjC</span> <span class="o">-</span><span class="n">weak_framework</span> <span class="n">UIKit</span>  <span class="o">-</span><span class="n">framework</span> <span class="n">CoreLocation</span>
</span></code></pre></td></tr></table></div></figure>


<p>4.修改完毕后，切换到XCConfigTest <strong>TARGETS</strong>视图查看设置。</p>

<pre><code>                            other link flag
</code></pre>

<p><img src="/images/post/2014-08-31-xcconfig-wen-jian-de-shi-yong/other_link_flag_test.png" alt="image" /></p>

<pre><code>                            Preprocessor Macros
</code></pre>

<p><img src="/images/post/2014-08-31-xcconfig-wen-jian-de-shi-yong/debug_flag_test.png" alt="image" /></p>

<p>5.添加测试代码对 <em>__TAOBAOTEST__</em>宏的测试。
查看<code>debug</code>状态下生效情况。</p>

<p><img src="/images/post/2014-08-31-xcconfig-wen-jian-de-shi-yong/xcconfig_test.png" alt="image" /></p>

<p>显然，<em>__TAOBAOTEST__</em>在<code>debug</code>状态下是生效的。
再测试下<code>release</code>状态下，是不生效的。</p>

<p>其它:</p>

<ul>
<li>1.<a href="https://github.com/cocoapods/cocoapods">CocoaPods</a>中使用<code>XCConfig</code>来进行配置。</li>
<li>2.<a href="https://github.com/jspahrsummers/xcconfigs">xcconfigs</a>，一个支持<code>XCConfig</code>的开源库，支持对<strong>iOS</strong>/<strong>Mac OS</strong>配置。</li>
</ul>


<h4>总结:不同的项目中，如果可以共用相同的配置环境，这种方式再方便不过了。</h4>
</div>
  
  


    </article>
  
  <div class="pagination">
    
      <a class="prev" href="/blog/page/8/">&larr; Older</a>
    
    <a href="/blog/archives">Blog Archives</a>
    
    <a class="next" href="/blog/page/6/">Newer &rarr;</a>
    
  </div>
</div>
<aside class="sidebar">
  
    <section>
  <h1>关于我</h1>
  <p>律威,QQ:309235009 微信:ksnowlv</p>
  <p>手机单机游戏/手机网游封神online/手机阅读/腾讯iOS地图客户端&实时公交&开放API(地图&街景)/iPad/iPhone淘宝客户端及性能优化</p>
  <p>目前在银客做银客/简理财/&#8230;</p>
  <p>能做一点,是一点;不求大成,不求一万年;积少成多,水到渠成!</p>
</section>
<section>
  <h1>最近发布</h1>
  <ul id="recent_posts">
    
      <li class="post">
        <a href="/blog/2017/04/26/android-drawable/">Android drawable</a>
      </li>
    
      <li class="post">
        <a href="/blog/2017/04/22/iOS-xia-shi-yong-ffmpeg/">iOS下使用ffmpeg</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/08/19/ios-you-xian-hou-tai-ren-wu/">iOS有限后台任务</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/08/19/android-xia-jie-ya-suo/">Android下gzip数据流解压缩</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/08/19/facebook-infer-de-shi-yong/">FaceBook-infer的使用</a>
      </li>
    
  </ul>
</section>
<section>
  <h1>分类</h1>
    <ul id="category-list"><li><a href='/blog/categories/android-jie-ya-suo/'>Android-解压缩 (1)</a></li><li><a href='/blog/categories/androidduo-xian-cheng/'>Android多线程 (3)</a></li><li><a href='/blog/categories/androidcha-jian/'>Android插件 (1)</a></li><li><a href='/blog/categories/androidhui-tu-./'>Android绘图。 (1)</a></li><li><a href='/blog/categories/androidwang-luo/'>Android网络 (1)</a></li><li><a href='/blog/categories/git/'>git (6)</a></li><li><a href='/blog/categories/githubbo-ke/'>github博客 (8)</a></li><li><a href='/blog/categories/ios/'>iOS (6)</a></li><li><a href='/blog/categories/ios-block/'>iOS-block (1)</a></li><li><a href='/blog/categories/ios-bug/'>iOS-Bug (2)</a></li><li><a href='/blog/categories/ios-memory/'>iOS-Memory (4)</a></li><li><a href='/blog/categories/ios-push/'>iOS-push (1)</a></li><li><a href='/blog/categories/ios-ui/'>iOS-UI (2)</a></li><li><a href='/blog/categories/ios-you-hua/'>iOS-优化 (1)</a></li><li><a href='/blog/categories/ios-nei-cun/'>iOS-内存 (1)</a></li><li><a href='/blog/categories/ios-ji-chu/'>iOS-基础 (3)</a></li><li><a href='/blog/categories/ios-duo-xian-cheng/'>iOS-多线程 (3)</a></li><li><a href='/blog/categories/ios-cun-chu/'>iOS-存储 (1)</a></li><li><a href='/blog/categories/ios-an-quan/'>iOS-安全 (1)</a></li><li><a href='/blog/categories/ios-wang-luo/'>iOS-网络 (13)</a></li><li><a href='/blog/categories/ios-jie-ya-suo/'>iOS-解压缩 (1)</a></li><li><a href='/blog/categories/ios-she-ji-mo-shi/'>iOS-设计模式 (1)</a></li><li><a href='/blog/categories/ios-diao-shi/'>iOS-调试 (1)</a></li><li><a href='/blog/categories/iosyou-hua/'>iOS优化 (1)</a></li><li><a href='/blog/categories/iosji-chu/'>iOS基础 (2)</a></li><li><a href='/blog/categories/iosyin-pin/'>iOS音频 (1)</a></li><li><a href='/blog/categories/mac/'>Mac (4)</a></li><li><a href='/blog/categories/mac-duo-xian-cheng/'>Mac-多线程 (1)</a></li><li><a href='/blog/categories/nginx/'>nginx (3)</a></li><li><a href='/blog/categories/php/'>php (3)</a></li><li><a href='/blog/categories/python/'>python (12)</a></li><li><a href='/blog/categories/swift/'>swift (11)</a></li><li><a href='/blog/categories/uml/'>UML (8)</a></li><li><a href='/blog/categories/xcode/'>Xcode (11)</a></li><li><a href='/blog/categories/chan-pin-she-ji/'>产品设计 (2)</a></li><li><a href='/blog/categories/gong-ju/'>工具 (2)</a></li><li><a href='/blog/categories/shu-ju-ku/'>数据库 (2)</a></li><li><a href='/blog/categories/sheng-huo-pian-duan/'>生活片段 (10)</a></li><li><a href='/blog/categories/zhi-ye-sheng-ya/'>职业生涯 (7)</a></li><li><a href='/blog/categories/du-shu/'>读书 (2)</a></li></ul>
</section>
<section>
  <h1>外部链接</h1>
    <ul id="外部链接">
    	<li><a href="https://developer.apple.com">苹果开发者中心</a> </li>
    	<li><a href="http://stackoverflow.com/questions/tagged/ios">stackoverflow</a></li>
    	<li><a href="http://ksnowlv.blog.163.com/blog/#m=0">ksnowlv网易博客</a></li>
	</ul>
</section>

  
</aside>

    </div>
  </div>
  <footer role="contentinfo"><p>
  Copyright &copy; 2017 - 律威 -
  <span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>

  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1253538110'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "v1.cnzz.com/z_stat.php%3Fid%3D1253538110%26online%3D1' type='text/javascript'%3E%3C/script%3E"));</script>

  <script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F4c1727a94ea20751730e8a556dbdbf82' type='text/javascript'%3E%3C/script%3E"));
</script>

</p>



</footer>
  

<script type="text/javascript">
      var disqus_shortname = 'ksnowlv';
      
        
        var disqus_script = 'count.js';
      
    (function () {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    }());
</script>








</body>
</html>
